<?php
/*
 * @Author: Zhang Yingying
 * @Date: 2020-11-04 17:41:50
 * @LastEditors: Zhang Yingying
 * @LastEditTime: 2020-12-03 23:45:00
 */
declare (strict_types = 1);

namespace app\validate;
use think\Validate;

class UsersValidate extends Validate
{
    /**
     * 定义验证规则
     * @var array
     */
    protected $rule = [
      'telephone'  => ['require', 'regex' => '/^1[345789]\d{9}$/'],
      'email' => ['require', 'regex' => '/^[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*@[a-zA-Z0-9]+([-_.][a-zA-Z0-9]+)*\.[a-z]{2,}$/'],
      'username' => 'require',
      'account' => 'require',
      'password' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
      'telephone' => '联系方式不正确',
      'username' => '用户名必填',
      'account' => '账户名必填',
      'password' => '密码',
      'email' => '邮箱不能为空'
    ];
}
